<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>以 WBMP 格式将图像输出到浏览器或文件</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.image2wbmp" class="refentry">
  <div class="refnamediv">
   <h1 class="refname">image2wbmp</h1>
   <p class="verinfo">(PHP 4 &gt;= 4.0.5, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">image2wbmp</span> &mdash; <span class="dc-title">以 WBMP 格式将图像输出到浏览器或文件</span></p>

  </div>
  <div class="refsect1 unknown-unknown-noteu" id="refsect1-function.image2wbmp-unknown-unknown-noteu">
   <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="methodname"><strong>image2wbmp</strong></span>
      ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>
     [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
     [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$threshold</code></span>
    ]] ) : <span class="type">int</span></div>

   <p class="para rdfs-comment">
    <span class="function"><strong>image2wbmp()</strong></span> 从
    <code class="parameter">image</code> 图像创建一个名为 <code class="parameter">filename</code> 的
    <acronym title="Wireless Bitmap">WBMP</acronym> 文件。<code class="parameter">image</code>
    参数是某个图像创建函数的返回值，例如 <span class="function"><a href="imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>。
   </p>
   <p class="para">
    <code class="parameter">filename</code> 参数是可选项，如果省略，则直接将原图像流输出。通过用
    <span class="function"><a href="header.html" class="function">header()</a></span> 发送 <acronym>image/vnd.wap.wbmp</acronym>
    的 Content-type，可以创建直接输出 WBMP 图像的 PHP 脚本。
   </p>
   <p class="para">
    <div class="example" id="example-3652">
     <p><strong>Example #1 <span class="function"><strong>image2wbmp()</strong></span> 例子</strong></p>
     <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'php.jpg'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$image&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">image_type_to_mime</span><span style="color: #007700">(</span><span style="color: #0000BB">IMAGETYPE_WBMP</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">image2wbmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;output&nbsp;the&nbsp;stream&nbsp;directly<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
     </div>

    </div>
   </p>
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
     WBMP 支持仅在 PHP 编译时加入了 GD-1.8 或更高版本时可用。
    </p>
   </p></blockquote>
   <p class="para">
    参见 <span class="function"><a href="imagewbmp.html" class="function">imagewbmp()</a></span>。
   </p>
  </div>

 </div></div></div></body></html>